import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86138
 * Date: 2024-11-24
 * Time: 23:23
 */
public class No_24 {
    public static int[] sum(int[] nums,int sum){
        int n = nums.length;
        int left = 0,right = n-1;
        while(left<right){
            if(nums[left]+nums[right]==sum){
                return new int[]{nums[left],nums[right]};S
            }else if(nums[left]+nums[right]>sum){
                right--;
            }else{
                left++;
            }
        }
        return new int[]{0};//照顾编译器
    }
    public static void main(String[] args) {
        int[] nums ={2,7,11,15,17,19,21};
        int t = 30;
        int[] ret = sum(nums,t);
        System.out.println(Arrays.toString(ret));
    }
}
